package com.home.homepage.service.postFooter.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.eig.common.entity.homepageentity.postFooter.TbArticle;
import com.eig.common.vo.Result;
import com.home.homepage.dao.postFooter.ArticleDao;
import com.home.homepage.service.postFooter.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ：YQ袁（2446806940@qq.com）
 * @date ：Created in 2022/12/11 15:34
 * @description：
 * @modified By：
 * @version:
 */
@Service
public class ArticleServiceImpl implements ArticleService {
    @Autowired
    private ArticleDao articleDao;
    @Override
    public Result updateArticleByNavId(TbArticle tbArticle) {
        UpdateWrapper<TbArticle> wrapper = new UpdateWrapper<>();
        System.out.println(tbArticle.getNavId()+"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
        wrapper.eq("nav_id" , tbArticle.getNavId());
        wrapper.set("art_title" ,tbArticle.getArtTitle());
        wrapper.set("art_desc",tbArticle.getArtDesc());
        int update = articleDao.update(null, wrapper);
        if(update>0){
            return new Result(2000,"修改成功");
        }
        return new Result(5000,"修改失败");

    }

    @Override
    public Result getArticleByNavId(TbArticle tbArticle) {
        QueryWrapper<TbArticle>wrapper = new QueryWrapper<>();
        wrapper.eq("nav_id", tbArticle.getNavId());
        List<TbArticle> tbArticles = articleDao.selectList(wrapper);

        return new Result(2000,"查询成功",tbArticles);
    }
}
